using System.Collections.Generic;
using System.Threading.Tasks;

namespace Services
{
    /// <summary>
    /// 权限服务接口，定义权限管理的核心功能
    /// </summary>
    public interface IPermissionService
    {
        /// <summary>
        /// 获取用户的所有权限
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns>权限名称列表</returns>
        Task<List<string>> GetUserPermissionsAsync(int userId);

        /// <summary>
        /// 检查用户是否拥有指定权限
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="permission">权限名称</param>
        /// <returns>true表示拥有权限，false表示没有权限</returns>
        Task<bool> HasPermissionAsync(int userId, string permission);

        /// <summary>
        /// 使用户的权限缓存失效
        /// </summary>
        /// <param name="userId">用户ID</param>
        Task InvalidateUserPermissionsCacheAsync(int userId);
        
        /// <summary>
        /// 将用户添加到指定角色
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="roleId">角色ID</param>
        Task AddUserToRoleAsync(int userId, int roleId);

        /// <summary>
        /// 从指定角色中移除用户
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="roleId">角色ID</param>
        Task RemoveUserFromRoleAsync(int userId, int roleId);

        /// <summary>
        /// 为角色添加权限
        /// </summary>
        /// <param name="roleId">角色ID</param>
        /// <param name="permissionName">权限名称</param>
        Task AddPermissionToRoleAsync(int roleId, string permissionName);

        /// <summary>
        /// 从角色中移除权限
        /// </summary>
        /// <param name="roleId">角色ID</param>
        /// <param name="permissionName">权限名称</param>
        Task RemovePermissionFromRoleAsync(int roleId, string permissionName);

        /// <summary>
        /// 获取角色的所有权限
        /// </summary>
        /// <param name="roleId">角色ID</param>
        /// <returns>权限名称列表</returns>
        Task<List<string>> GetRolePermissionsAsync(int roleId);
    }
} 